package com.taotao.rest.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.json.MappingJacksonValue;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.rest.pojo.CatResult;
import com.taotao.rest.service.IItemCatService;

/**
 * 商品类目控制层
 * 
 * @author Administrator
 *
 */
@Controller
@RequestMapping("/item/cat")
public class ItemCatController {
	@Autowired
	private IItemCatService itemCatService;

	/**
	 * 获取分类类表
	 * 
	 * @param callback
	 * @return
	 */
	// @RequestMapping(value = "/list", produces =
	// MediaType.APPLICATION_JSON_VALUE
	// + ";charset=utf-8")
	// @ResponseBody
	// public String getItemCatList(String callback) {
	// CatResult catResult = this.itemCatService.getItemCat();
	// String jsonStr = JsonUtils.objectToJson(catResult);
	// return callback + "(" + jsonStr + ");";
	// }

	@RequestMapping("/list")
	@ResponseBody
	public Object getItemCatList(String callback) {
		CatResult catResult = itemCatService.getItemCat();
		MappingJacksonValue mappingJacksonValue = new MappingJacksonValue(
				catResult);
		mappingJacksonValue.setJsonpFunction(callback);
		return mappingJacksonValue;
	}

}
